
package com.faner.fast.security.service;

import cn.hutool.core.util.StrUtil;
import com.faner.fast.constant.CommonConstants;
import com.faner.fast.upms.model.SysMenuDO;
import com.faner.fast.upms.model.SysUserDO;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;
import java.util.List;

/**
 * 扩展用户信息
 * @作者 faner
 * @创建时间 2021/2/19 16:05
 */
@Getter
@AllArgsConstructor
public class FastUser implements UserDetails {

    /**
     * 用户ID
     */
    private Long id;

    /**
     * 部门ID
     */
    private Long deptId;

    /**
     * 账号
     */
    private String username;

    /**
     * 是否被禁用
     */
    private Boolean enabled;

    /**
     * 密码
     */
    private String password;

    /**
     * 权限信息
     */
    private Collection<? extends GrantedAuthority> authorities;

    public FastUser() {
    }

    public FastUser(Long id, Long deptId, String username, String password, Boolean enabled, Collection<? extends GrantedAuthority> authorities) {
        this.id = id;
        this.deptId = deptId;
        this.username = username;
        this.password = password;
        this.enabled = enabled;
        this.authorities = authorities;
    }

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return authorities;
    }

    @Override
    public String getPassword() {
        return password;
    }

    @Override
    public String getUsername() {
        return username;
    }
    @JsonIgnore
    @Override
    public boolean isAccountNonExpired() {
        return true;
    }
    @JsonIgnore
    @Override
    public boolean isAccountNonLocked() {
        return true;
    }
    @JsonIgnore
    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return enabled;
    }


}
